<?php if ($this->pageCount): ?>

    <?php
    /**
     * Gets all parameters and strips the user parameters from them
     *
     * @param int $page
     * @return string the query string
     */
    function getParametersAsQuery($page) {
        $prms  = Zend_Controller_Front::getInstance()->getRequest()->getParams();
        $uprms = Zend_Controller_Front::getInstance()->getRequest()->getUserParams();

        foreach ( $uprms as $k => $v ) {
            if ( isset($prms[$k]) ) {
                unset($prms[$k]);
            }
        }
        unset($uprms);

        $prms = array_map('stripslashes', $prms);

        $prms['page'] = (int)$page;
        return '?'.http_build_query($prms);
    }
    ?>

    <div class="paginationControl">
        <ul id="icon" >

            <li title="Previous Page">
                <?php if (isset($this->previous)): ?>
                    <a href="<?php echo getParametersAsQuery($this->previous); ?>"
                       rel="nofollow">
                        Previous
                    </a>
                <?php else: ?>
                    <span>Previous</span>
                <?php endif ?>
            </li>

            <?php foreach ($this->pagesInRange as $page): ?>
                <li>
                    <?php if ($page == $this->current): ?>
                        <span><u><?php echo $page; ?></u></span>
                    <?php else: ?>
                        <a href="<?php echo getParametersAsQuery($page); ?>"
                           rel="nofollow">
                            <?php echo $page; ?>
                        </a>
                    <?php endif;?>
                </li>
            <?php endforeach; ?>

            <li title="Next Page">
                <?php if (isset($this->next)): ?>
                    <a href="<?php echo getParametersAsQuery($this->next); ?>"
                       rel="nofollow">
                        Next
                    </a>
                <?php else: ?>
                    <span>Next</span>
                <?php endif; ?>
            </li>

        </ul>
    </div>
<?php endif; ?>

